Incorporate recordPlot functionality for recording and replaying plots as objects - #686
Open
grantmcdermott wants to merge 1 commit into
Open
Incorporate recordPlot functionality for recording and replaying plots as objects#686grantmcdermott wants to merge 1 commit into
recordPlot functionality for recording and replaying plots as objects#686grantmcdermott wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #121
By adding
grDevices::recordPlot()to the very end of the maintinyplot()function, we gain the ability to record (assign) plots as objects and then replay them later.Here's a little
plt_addgotcha, though...But note that nothing stops us from layering immediately... and we can record and replay from a later layer too. Here, demonstrating with a theme to drive home the point.
Note: Due to the "canvas" nature of base graphics, we can't suppress the initial display. Unless, that is, we do something tricksy like write to a dummy device / file on disk and then recall later.
Created on 2026-08-20 with reprex v2.1.1
Discussion: To be clear, I'm not convinced that we want to add this functionality. But some quick testing, at least, suggests that it doesn't add any real overhead. Apart from the
plt_add()gotcha that I highlight above, I also haven't hit any unintended side effects. Still, I'd like others to kick the tyres too, before we consider whether merging is a good idea.